const qiniu = require('qiniu')
const nanoid = require('nanoid')

var mac = new qiniu.auth.digest.Mac("03FNGagRAsv4Aga41uLWSTqi8aRSt5YKaoJg2vdz", "zfY4ECP2OwcMSEqz515t4M7K3TXmyHm65HRrxSLA");
var config = new qiniu.conf.Config();
//config.useHttpsDomain = true;
config.zone = qiniu.zone.Zone_z2;
var bucketManager = new qiniu.rs.BucketManager(mac, config);


var resUrl = 'http://img.zybus.com/uploads/allimg/140322/1-140324155P0-50.jpg';
var bucket = "koaone";
var key = "susu.png";
bucketManager.fetch(resUrl, bucket, key, function(err, respBody, respInfo) {
    if (err) {
        console.log(err);
        //throw err;
    } else {
        if (respInfo.statusCode == 200) {
            console.log(respBody.key);
            console.log(respBody.hash);
            console.log(respBody.fsize);
            console.log(respBody.mimeType);
        } else {
            console.log(respInfo.statusCode);
            console.log(respBody);
        }
    }
});